﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace CodeAngel.Domain.Framework
{
    #region IUser
    
    public  interface IUser
    {
        string UserName { get; }
        string Password { get; }
    }

    #endregion

    #region Permission

    public enum Permission
    {
        Create,
        Read,
        Update,
        Delete,

        CreateRead,
        CreateUpdate,
        CreateDelete,

        CreateReadUpdate,
        CreateReadDelete,
        CreateUpdateDelete,

        CreateReadUpdatedDelete,

        ReadUpdate,
        ReadDelete,

        ReadUpdateDelete,

        UpdateDelete

    }

    #endregion

    #region MissingUserException

    /// <summary>
    /// An exception that indicates that an IUser object was expected but is missing.
    /// </summary>
    public class MissingUserException : Exception
    {
        public MissingUserException() { }
    }

    #endregion

    #region LogInFailedException

    public class LogInFailedException : Exception
    {
        public LogInFailedException(string message, string userName)
            : base(message)
        {
            this.UserName = userName;
        }

        public LogInFailedException(Exception innerException, string userName)
            : base("Login failed.", innerException)
        {
            this.UserName = userName;
        }

        public string UserName { get; private set; }
    }

    #endregion

    #region NotAuthorizedException

    /// <summary>
    /// Indicates a user does not have permission to perform a certain operation.
    /// </summary>
    public class NotAuthorizedException : Exception
    {
        public NotAuthorizedException(string userName, string operation)
            : base(userName + " is not authorized to perform the following operation: " + operation)
        {        }
    }

    #endregion
}
